package org.arestaurant;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class TableServices {
    public static JSONArray getTableList() {
        JSONArray tableList = null;
        InputStream in;
        try {
            ConnectionServices.connectHttp("/arestaurant/control/getTableList");
            in = new BufferedInputStream(ConnectionServices.HTTP_CONNECTION.getInputStream());
            BufferedReader rd = new BufferedReader(new InputStreamReader(in));
            JSONObject jsonObj;
            jsonObj = new JSONObject(rd.readLine());
            tableList = (JSONArray) jsonObj.getJSONArray("tableList");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return tableList;
    }
}